<template>
    <div class="page">
        <AdminTabsP :list="tabList" v-model:active="tabActive" fixed />
        <AdminSearchInputP @search="onSearch" />

        <template v-if="!isLoading">
            <div class="work-list" v-if="list.length">
                <div class="work-item" v-for="item in list" :key="item.id">
                    <img
                        class="work-item__img"
                        :src="
                            item.file +
                            '?x-oss-process=image/watermark,image_' +
                            toBase64(
                                'water/logo_white.png?x-oss-process=image/resize,P_30'
                            ) +
                            ',g_center,t_60'
                        "
                    />
                    <div class="work-item__info">
                        <div class="work-info__top">
                            <div class="work-info__title">
                                {{ item.name }}
                            </div>
                            <div class="work-info__btn_group">
                                <span class="btn" @click="onJumpUrl(item.url)">
                                    继续编辑
                                </span>
                                <el-popconfirm
                                    title="是否确认删除？"
                                    @confirm="onDelMyWork(item)"
                                >
                                    <template #reference>
                                        <span class="btn"> 删除 </span>
                                    </template>
                                </el-popconfirm>
                            </div>
                        </div>

                        <div class="work-info__bottom">
                            <div class="work-info__group">
                                <img
                                    :src="`${_oss_}images/admin/works/time.png`"
                                />
                                {{ item.createtime }}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <el-empty :image-size="150" v-else />
        </template>
    </div>
</template>
<script setup>
import { useContent } from ".";

const {
    isLoading,
    tabActive,
    tabList,
    list,
    onJumpUrl,
    onDelMyWork,
    onSearch,
    GetList,
} = useContent();

await GetList();
</script>
<style lang="scss" scoped>
.page {
    width: 100%;
    padding: 0 16px;
}

.work-list {
    height: calc(100% - 145px);
    overflow: auto;

    .work-item {
        display: flex;
        padding: 12px;
        border-bottom: 1px solid #ddd;

        &__img {
            flex-shrink: 0;
            width: 100px;
            height: 68px;
            object-fit: cover;
            border-radius: 6px;
        }

        &__info {
            width: 100%;
            height: 65px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding-top: 10px;
            padding-left: 17px;
        }

        .work-info__top {
            display: flex;
            align-items: center;

            .work-info__btn_group {
                margin-left: auto;
                color: #5185fb;
                font-size: 14px;

                .btn {
                    margin-left: 20px;
                    user-select: none;
                    cursor: pointer;
                }
            }
        }

        .work-info__bottom {
            display: flex;
            align-items: center;
            margin-top: auto;
            color: #666;

            .work-info__group {
                display: flex;
                align-items: center;
                margin-right: 40px;

                img {
                    margin-right: 4px;
                }
            }
        }
    }
}
</style>
